//
//  YLAccount.m
//  YLFinanceService
//
//  Created by she1323 on 2017/8/23.
//  Copyright © 2017年 she1323. All rights reserved.
//

#import "YLAccount.h"
#import <YYModel.h>
@implementation YLAccount

+ (instancetype)accountWithDict:(NSDictionary *)dict
{
   YLAccount *account = [YLAccount yy_modelWithDictionary:dict];
   account.token = [NSString stringWithFormat:@"Bearer %@", account.token];
   return account;
}

- (void)setPhoneNumber:(NSString *)phoneNumber
{
    _phoneNumber = phoneNumber;
    if (phoneNumber.length > 8) {
       _userName = [phoneNumber stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
    }
    
}


// 序列化
- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [self yy_modelEncodeWithCoder:aCoder];
//    [aCoder encodeObject:self.phoneNumber forKey:@"phoneNumber"];
//    [aCoder encodeObject:self.userName forKey:@"userName"];
//    [aCoder encodeObject:self.token forKey:@"token"];
//    [aCoder encodeObject:self.aa forKey:@"aa"];
}

// fang
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    return [self yy_modelInitWithCoder:aDecoder];
//    if (self = [super init]) {
//        self.phoneNumber = [aDecoder decodeObjectForKey:@"phoneNumber"];
//        self.userName = [aDecoder decodeObjectForKey:@"userName"];
//        self.token = [aDecoder decodeObjectForKey:@"token"];
//        self.aa = [aDecoder decodeObjectForKey:@"aa"];
//    }
//    return self;
}

- (id)copyWithZone:(NSZone *)zone
{
    return [self yy_modelCopy];
}

- (NSUInteger)hash
{
    return [self yy_modelHash];
}

- (BOOL)isEqual:(id)object
{
    return [self yy_modelIsEqual:object];
}



@end
